package kr.co.bettersoft.waitnumberstoret.activity;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.Toast;

public class LoginActivity extends Activity{

	String TAG = "LoginActivity";
	
	int vibrateCnt = 3;
	Vibrator Vi;
	
	// 핸들러
	Handler handler = new Handler(){
		@Override
		public void handleMessage(Message msg){
			Bundle b = msg.getData();
			try{
//				if(b.getInt("order")==1){
//					// 러닝바 실행
//					if(pb1==null){
//						pb1=(ProgressBar) findViewById(R.id.event_list_ProgressBar01);
//					}
//					pb1.setVisibility(View.VISIBLE);
//				}else if(b.getInt("order")==2){
//					// 러닝바 종료
//					if(pb1==null){
//						pb1=(ProgressBar) findViewById(R.id.event_list_ProgressBar01);
//					}
//					pb1.setVisibility(View.INVISIBLE);
//				}
				if(b.getInt("showErrToast")==1){		// 일반 에러 토스트
//					Toast.makeText(EventListActivity.this, R.string.error_message, Toast.LENGTH_SHORT).show();
				}
				if(b.getInt("showNetErrToast")==1){		// 네트워크 에러 토스트
//					Toast.makeText(EventListActivity.this, R.string.network_error, Toast.LENGTH_SHORT).show();
				}
			}catch(Exception e){
				e.printStackTrace();
			}
		}
	};
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		requestWindowFeature(Window.FEATURE_NO_TITLE );	// 타이틀바 제거
		setContentView(R.layout.login_activity);
		Log.w(TAG,"LoginActivity onCreate");
		
		Vi = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
		
		
		//vibrateThreeTimes();		// 진동 테스트. 나중에 고객용 어플에서 사용.
		
	}
	
	// 진동
	public void vibrateThreeTimes(){
		new Thread(
				new Runnable(){
					public void run(){
						try {
							for(int i=0; i<vibrateCnt; i++){
								Vi.vibrate(1000);
								Thread.sleep(2000);
							}
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
					}
				}
		).start();
	}
	
	
}
